<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
   <title>添加成绩查看</title>
    <script src="../../script/mui.min.js"></script>
    <script src="../../script/jquery.min.js"></script>
    <script src="../../script/jquery.knob.js"></script>
    <link rel="stylesheet" href="../../css/mui.min.css" />
    <link rel="stylesheet" href="../../css/CFNetPP_Base.css">
    <link rel="stylesheet" href="../../css/base.css"/>
    <link rel="stylesheet" href="../../css/testscore.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <style>
        body,html{
            width: 100%;
            /* overflow-x: hidden; */
        }
        th{
            font-size: 20px;
            text-align: center;
            height: 40px;
            
        }
        td{
            font-size: 18px;
            text-align: center;
            height:40px;
            border: 1px solid #F2F2F2;
        }
        table{
            width: 100%;            
        }
        .weih{
            width: 130px;
        }
        .imgs{
            margin-bottom: 3px;     
            margin-right: 10px;    
            width: 10px;
            height: 10px;
            vertical-align:middle;
        }
        .imgse{
            margin-bottom: 3px;     
            margin-left: 10px;    
            width: 15px;
            height: 15px;
            vertical-align:middle;
        }
        
        .setup{  
            padding: 5px;
            text-align: center;
        }
    </style>
</head>
<body  style="overflow:-Scroll;overflow-y:hidden" >
    <table id="grade">
    </table>
    <div class="noSign" hidden="hidden" id="noData">
            <img src="../../image/icon_img.png" width="60%">
            <p class="font16 top_15 base_dark_grey" >
                暂无数据
            </p>
        </div>
        <div class="loadFailure" hidden="hidden" id="noNet">
            <img src="../../image/icon_img01.png" width="60%">
            <p class="" >
                数据加载失败
            </p>
            <p>
                请检查您的网络
            </p>
            <button type="button" class="mui-btn mui-btn-outlined" onclick="loadNewData()">
                重新加载
            </button>
        </div>
</body>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script src="../../script/common.js"></script>
<script src="../../script/timeStampTool.js"></script>
<script src="../../script/processing_images.js"></script>
<script type="text/javascript" src="../../script/MD5.js"></script>
<script type="text/javascript" src="../../script/requestTool.js"></script>
<script type="text/javascript" src="../../script/mui.min.js"></script>
<script type="text/javascript">
    var datase = [];//自评分数
    // 互评分数
    var dataseh = [];
    // 教师评分数
    var dataset = [];
    // 打分项
    var datasex = [];
    var datas = new Object();
    // var ssd = [];
    var cfevals = "";
    var cs = [];
    // var ssde = [];
    var vid = "";
    var pid = "";
    var cid = "";

    var totalTea = 0;   //三个是总分
    var totalStu = 0;
    var totalSelf = 0;

    var weight = "";

    apiready = function(){
        datas = api.pageParam.data;
        if(datas == "null"){
            $('#noNet').show();
            api.toast({
                    msg : '网络错误!!!',
                    duration : 2000,
                    location : 'bottom'
                });

        }else{

            vid = api.pageParam.vid;
            pid = api.pageParam.pid;
            cid = api.pageParam.cid;
            initGuDingFrame();
            loaddate();
        }
        api.addEventListener({
            name:'mylist_up'
        },function(ret,err){
            loaddate();
        });

        api.addEventListener({
                name: 'scrollTop'
            }, function(ret, err) {

                $('html,body').animate({scrollTop: '0px'}, 100);

            });
    };
    function initGuDingFrame () {
        datasex = [];
        var ssd = datas.data.scorelist;
        for(var i = 0;i<ssd.length;i++){
                var item = {};
                item.title = datas.data.scorelist[i].names; // 评分项名称
                item.score = datas.data.scorelist[i].score; // 评分项的总分数
                item.fallscore = datas.data.scorelist[i].fallscore; // 评分项or小项（小项的每次扣分为0）
                datasex.push(item);
        }
    }
    function loaddate(){
        totalTea = 0;
        totalStu = 0;
        totalSelf = 0;

        var params = {
                vid : vid,
                uid : $api.getStorage('cfnetppuid'),
                jid : $api.getStorage('cfnetppjxid'),
                pid : pid,
                cid : cid,
        };
//      var url_cf = "http://base.cfnet.org.cn/course/Sitenow_Normal/getSitenowRealdScore";
        // showProgress();
        cfnetppPOST(url_getSitenowRealdScore, params, true, function(data, status) {
            api.hideProgress();
            // alert(JSON.stringify(params));
            if(status == 'success'){
                if (data.code == 200) {
                    // alert(JSON.stringify(data));
                    inits(data);
                    weight = data.weight;
                    $('#noData').hide();
                    $('#noNet').hide();
                }else{

                    $('#noData').show();
                    $('#noNet').hide();
                }
                
            }else{
                $('#noData').hide();
                $('#noNet').show();
            }
        });
    }
    // 获取打分项信息
    function inits(gradedata){

        $('#grade').html("");
        var dar = '<tbody>' + '<tr>' + '<td>' + '项目'  + '</td>' + '<td>' + '分数'  + '</td>' +'<td class="weih">' + '老师/学生/自评'  + '</td>' + '</tr>' + '<tr>' + '<td>' + '总分'  + '</td>' + '<td id="totalAllScore">'+ '</td>' +'<td id="teaStuSelfScore" class="weih">' + '</td>' + '</tr>';
        var resultData = gradedata.data;
        dataset = [];
        for (var i = 0; i < resultData.length; i++) {
            var item = {};
            item.name = resultData[i].name;
            item.score = resultData[i].score;
            if (resultData[i].teascore == "未评分") {
                item.teascore = "--"
            }else{
                item.teascore = parseInt(resultData[i].teascore);
            }
            if (resultData[i].peerscore == "未评分") {
                item.peerscore = "--"
            }else{
                item.peerscore = parseInt(resultData[i].peerscore);
            }
            if (resultData[i].myselfscore == "未评分") {
                item.myselfscore = "--"
            }else{
                item.myselfscore = parseInt(resultData[i].myselfscore);
            }
            dataset.push(item);
        }

        for(var i = 0;i<datasex.length;i++){

            if(datasex[i].fallscore == "0"){
                dar = dar + '<tr style="background-color: #f0f0f0;">' + '<td class="setup base_title_font">' + dataset[i].name + '</td>' + '<td class="base_title_font" style="width:50px;">' + dataset[i].score + '</td>' +'<td  class="weih base_content_font">' + dataset[i].teascore + '/' + dataset[i].peerscore + '/' + dataset[i].myselfscore + '</td>' +'</tr>';
                if (dataset[i].teascore == "--") {
                    totalTea = "--";
                }else{
                    totalTea += parseInt(dataset[i].teascore);
                }

                if (dataset[i].peerscore == "--") {
                    totalStu = "--";
                }else{
                    totalStu += parseInt(dataset[i].peerscore);
                }
                
                if (dataset[i].myselfscore == "--") {
                    totalSelf = "--";
                }else{
                    totalSelf += parseInt(dataset[i].myselfscore);
                }
            
                
            }else{
                dar = dar + '<tr style="background-color: #ffffff;">' + '<td class="setup base_content_font">' + dataset[i].name + '</td>' + '<td class="base_content_font" style="width:50px;">' + dataset[i].score + '</td>' +'<td class="weih base_content_font">' + dataset[i].teascore + '/' + dataset[i].peerscore + '/' + dataset[i].myselfscore + '</td>' +'</tr>';
                var dangqianfen = parseInt(dataset[i].score);

                if (dataset[i].teascore == "--") {
                    
                }else{
                    totalTea = totalTea - (dangqianfen - parseInt(dataset[i].teascore));
                }

                if (dataset[i].peerscore == "--") {
                    
                }else{
                   totalStu = totalStu - (dangqianfen - parseInt(dataset[i].peerscore));
                }

                if (dataset[i].myselfscore == "--") {
                    
                }else{
                    totalSelf = totalSelf - (dangqianfen - parseInt(dataset[i].myselfscore));
                }
                
                
                
            }
            

        }

        // x.innerHTML=dar + '</tbody>';
        $('#grade').html(dar + '</tbody>');
        $('#teaStuSelfScore').html((totalTea+'/'+totalStu+'/'+totalSelf));

        var tea = 0;
        var stu = 0;
        var my = 0;
        if (totalTea == "--") {
            tea = 0;
        } else {
            tea = totalTea;
        }
        if (totalStu == "--") {
            stu = 0;
        } else {
            stu = totalStu;
        }
        if (totalSelf == "--") {
            my = 0;
        } else {
            my = totalSelf;
        }
        // alert(JSON.stringify(weight));
        var aaa = weight.teacher / 100;
        var bbb = weight.student / 100;
        var ccc = weight.oneself / 100;
        
        var resultValue = (tea * aaa + stu * bbb + my * ccc).toFixed(2);
        resultValue = parseFloat(resultValue);
        $('#totalAllScore').html((resultValue));
    }


    function loadNewData() {
        $('#noNet').hide();
        $('#noData').hide();
        api.sendEvent({
            name: 'loadnew'
        });
        api.closeFrameGroup({
               name: 'groups'
           });
    }
</script>
</html>